import java.util.*;
public class lk58 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuffer s1 = new StringBuffer(s);
        int k=sc.nextInt();
        while(k-->0){
            char c = s1.charAt(0);
            s1.deleteCharAt(0);
            s1.append(c);
        }
        System.out.println(s1.toString());
    }
}
